#!/usr/bin/env python
"""
GitCode MCP服务器主入口模块
"""
import logging
import sys
import asyncio
from .server import mcp, main as server_main

# 配置日志
logging.basicConfig(
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    handlers=[
        logging.StreamHandler(sys.stdout),  # 明确输出到标准输出
        logging.FileHandler("gitcode_mcp.log")
    ]
)
logger = logging.getLogger("gitcode_mcp.__main__")

def main():
    """主函数入口点"""
    logger.info("正在初始化GitCode MCP服务器...")
    try:
        # 调用server.py中的主函数
        server_main()
    except KeyboardInterrupt:
        logger.info("服务器被用户中断")
    except Exception as e:
        logger.error(f"服务器启动失败: {e}", exc_info=True)
        raise

if __name__ == "__main__":
    main() 